package br.com.pd.invocation;

import java.io.Serializable;

import br.com.pd.app.server.ConsumerIF;
import br.com.pd.app.server.ProducerIF;
import br.com.util.PropertiesLoader;

public class ConnectionFactory implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3983308634639130210L;
	
	private String location;
	private int port;
	

	public ConnectionFactory(){
		this.location = PropertiesLoader.getInstance().getPropertie(PropertiesLoader.LOCATION_REMOTE_OBJECT);
		this.port = Integer.parseInt(PropertiesLoader.getInstance().getPropertie(PropertiesLoader.PORT_LOCATION_REMOTE_OBJECT));
	}
	
	public ConsumerIF registerConsumer(ConsumerIF consumer){
		ConsumerRequestor tmpConsumer = new ConsumerRequestor(this.location, this.port);
		tmpConsumer.invoke(this.location, this.port, null);
		return tmpConsumer;
	}
	
	public ProducerIF registerProvider(ProducerIF producer){
		ProducerRequestor tmpConsumer = new ProducerRequestor(this.location, this.port);
		return tmpConsumer;
	}
	
	
	
	
	
}
